from django.db import models

# Create your models here.
from django.db import models
# 导入自定义抽象类
from db.basemodel import BaseBean

# Create your models here.
# 订单信息模型
class OrderInfoBean(BaseBean):
    # 订单ID
    order_id = models.CharField(max_length=128,primary_key=True,verbose_name="订单ID")
    # 地址ID
    address = models.ForeignKey("user.AddressBean",verbose_name="地址ID")
    # 用户ID
    user = models.ForeignKey("user.UserBean",verbose_name="用户ID")
    # 支付方式  --默认支付宝
    PAY_METHOD_CHOICES = (
        (1,"货到付款"),
        (2,"支付宝"),
        (3,"微信支付"),
        (4,"银联支付")
    )

    pay_method = models.SmallIntegerField(choices=PAY_METHOD_CHOICES,default=2,verbose_name="支付方式")
    # 订单总数目
    order_total_count = models.IntegerField(default=1,verbose_name="订单总数目")
    # 订单总金额
    order_total_price = models.DecimalField(max_digits=10,decimal_places=2,verbose_name="订单总金额")
    # 订单运费
    freight_price = models.DecimalField(max_digits=10,decimal_places=2,verbose_name="订单运费")
    # 支付状态 --默认是待支付
    ORDER_STATUS_CHOICES = (
        (1,"待支付"),
        (2,"待发货"),
        (3,"待收货"),
        (4,"待评价"),
        (5,"已完成")
    )
    order_status = models.SmallIntegerField(choices=ORDER_STATUS_CHOICES,default=1,verbose_name="订单状态")
    # 支付编号
    pay_number = models.CharField(max_length=128,verbose_name="支付编号")
    class Meta:
        db_table = "table_order_info"
        verbose_name = "订单信息"
        verbose_name_plural = verbose_name

# 订单商品模型
class OrderGoodsBean(BaseBean):
    # 订单ID
    order = models.ForeignKey("OrderInfoBean",verbose_name="订单信息")
    # 商品SKU ID
    goods_sku = models.ForeignKey("goods.GoodsSKUBean",verbose_name="商品SKU")
    # 商品数量
    count = models.IntegerField(default=1,verbose_name="商品数量")
    # 商品价格
    price = models.DecimalField(max_digits=10,decimal_places=2,verbose_name="商品价格")
    # 评论
    comment = models.CharField(max_length=256,verbose_name="评论")
    class Meta:
        db_table = "table_order_goods"
        verbose_name = "订单商品"
        verbose_name_plural = verbose_name